home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.sprintlink.net!mv!usenet
- From: ENGR@GSSI.MV.COM (Michael Furman)
- Subject: Re: "free"ing classes when the "new" is inside a function
- Message-ID: <DoIwyp.HHw@mv.mv.com>
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- Organization: GSSI
- Date: Tue, 19 Mar 1996 16:40:00 GMT
- References: <4ic7a5$94u@falcon.ccs.uwo.ca>
- X-Newsreader: WinVN 0.99.7
- X-Nntp-Posting-Host: gssi.mv.com
-
- In article <4ic7a5$94u@falcon.ccs.uwo.ca>, turnbull@canlon.physics.uwo.ca
- says...
- >
- >I have code something like
- >
- >MyClass* Myfunc(){
- > Class* value;
- >.
- >.
- > value = new MyClass(........); <- 1 of several possible
- constructors
- >.
- > return value;
- >}
- >
- >
- >------ in main---------
- >.
- >Class* value;
- >value=Myfunc();
- >.
- >
- >How do I free up the memory allocated to value?
- >delete value won't do it.
-
- Just "delete value;"
- It will first call destructor for this class (if exist) and then free memory.
-
- >
- >Thanks.
- >
- >David Turnbull
- >Department of Physics
- >University of Western Ontario
- >London, Ontario, Canada
- >
-
- --
- <<< If you received it by E-mail: it is a copy of post to the newsgroup >>>
- ---------------------------------------------------------------
- Michael Furman, (603)893-1109
- Geophysical Survey Systems, Inc. fax:(603)889-3984
- 13 Klein Drive - P.O. Box 97 engr@gssi.mv.com
- North Salem, NH 03073-0097 71543.1334@compuserve.com
- ---------------------------------------------------------------
-
-